package jrain.flow.engine.dis;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import jrain.flow.engine.bean.NodeInstance;
import jrain.flow.engine.uitls.FlowUtils;

public class DispatchServiceImpl implements DispatchService {

	private ExecutorService executorService = Executors.newCachedThreadPool();

	public void doNodeSplit(NodeInstance nodeInstance) {
		executorService.submit(() -> {
			try {
				FlowUtils.getNodeService().doNodeSplit(nodeInstance);
			} catch (Throwable t) {
				// TODO加入异常处理节点
			}
		});
	}

	public void doNode(NodeInstance nodeInstance) {
		executorService.submit(() -> {
			try {
				FlowUtils.getNodeService().doNode(nodeInstance);
			} catch (Throwable t) {
				// TODO加入异常处理节点
			}
		});
	}

	public void doNodeJoin(NodeInstance nodeInstance) {
		executorService.submit(() -> {
			try {
				FlowUtils.getNodeService().doNodeJoin(nodeInstance);
			} catch (Throwable t) {
				// TODO加入异常处理节点
			}

		});
	}

}
